package com.ap.core.domain;

import java.util.List;

import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.joda.time.LocalDateTime;

import com.ap.core.common.types.DistributorCategoryCode;
import com.ap.core.cxf.jaxb.common.ActivationStatus;

import javax.persistence.*;

/**
 * User: Ranjit.Singh
 */
@Entity
@Table(name = "T_DISTRIBUTOR")
@AttributeOverride(name = "id",column = @Column(name = "DISTRIBUTOR_ID"))
@TypeDef(name = "id", typeClass = Long.class)
public class Distributor extends Identifiable<Long> {

	private static final long serialVersionUID = 5180845106091590283L;
	
	@Column(name = "DISTRIBUTOR_IDENTIFICATION", nullable = false)
    private String distributorIdentification;

	@Column(name = "DISTRIBUTOR_NAME", nullable = false)
    private String distributorName;
	
	@Column(name = "ACTIVATION_STATUS_CODE")
	@Enumerated(EnumType.STRING)
    private ActivationStatus activationStatusCode;
    
    @Embedded
    @AttributeOverride(name = "sortCode", column = @Column(name = "SETTLEMENT_SORT_CODE", nullable = false))
    private SortCode settlementSortCode;

    @Embedded
    @AttributeOverride(name = "accountNumber", column = @Column(name = "SETTLEMENT_ACCOUNT_NUMBER"))
    private AccountNumber settlementAccountNumber;
    
    @Embedded
    @AttributeOverride(name = "rollNumber", column = @Column(name = "SETTLEMENT_ROLL_NUMBER"))
    private RollNumber settlementRollNumber;

    @Column(name = "ACCOUNT_IDENTIFIER", nullable = false)
    private String accountIdentifier;
       
    
    @Column(name = "DISTRIBUTOR_CATEGORY_CODE")
    @Enumerated(EnumType.STRING)
    private DistributorCategoryCode distributorCategoryCode;
    
    @Column(name = "SITE_NAME")
    private String siteName;
    
    
    @Column(name = "TARGET_URI")
    private String targetUri;
    
    @Column(name = "LAST_UPDATE_TMSTMP")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
    private LocalDateTime lastUpdateTimestamp;
    
    @Column(name = "FILE_ID")
    private Integer fileId;
        
    @OneToMany(cascade = CascadeType.ALL , mappedBy = "distributorId")
    private List<DistributorEndPointUrl> distributorEndPointUrlList;
    
    private Distributor(){}


    public String getDistributorIdentification() {
        return distributorIdentification;
    }


    public String getDistributorName() {
        return distributorName;
    }

	public List<DistributorEndPointUrl> getDistributorEndPointUrlList() {
		return distributorEndPointUrlList;
	}

        public SortCode getSettlementSortCode() {
        return settlementSortCode;
    }


	/**
	 * @return the activationStatusCode
	 */
	public ActivationStatus getActivationStatusCode() {
		return activationStatusCode;
	}

	/**
	 * @return the settlementAccountNumber
	 */
	public AccountNumber getSettlementAccountNumber() {
		return settlementAccountNumber;
	}


	/**
	 * @return the settlementRollNumber
	 */
	public RollNumber getSettlementRollNumber() {
		return settlementRollNumber;
	}


	/**
	 * @return the accountIdentifier
	 */
	public String getAccountIdentifier() {
		return accountIdentifier;
	}


	/**
	 * @return the distributorCategoryCode
	 */
	public DistributorCategoryCode getDistributorCategoryCode() {
		return distributorCategoryCode;
	}


	/**
	 * @return the siteName
	 */
	public String getSiteName() {
		return siteName;
	}


	/**
	 * @return the targetUri
	 */
	public String getTargetUri() {
		return targetUri;
	}


	/**
	 * @return the lastUpdateTimestamp
	 */
	public LocalDateTime getLastUpdateTimestamp() {
		return lastUpdateTimestamp;
	}


	/**
	 * @return the fileId
	 */
	public Integer getFileId() {
		return fileId;
	}


}
